Suppress benign camembert/roberta model type warning in ThEnTranslator - #1215
Conversation
Co-authored-by: wannaphong <8536487+wannaphong@users.noreply.github.com>
Co-authored-by: wannaphong <8536487+wannaphong@users.noreply.github.com>
|
@copilot There are changes in dev branch to fix the errors occured in Python 3.13. Merge the changes and run the tests again. |
|
@copilot The dev branch is updated. Some code were refactored. Please resync with it. The test suite got refactored and now we have 4-tier of test cases located in four test suites: core, compact, extra, noauto - depends on their dependency requirements. See the test suite refactoring and naming conventions in this merged PR |
Resynced with dev branch in commit ee75831. The branch now includes the 4-tier test suite refactoring (core, compact, extra, noauto) with updated naming conventions. The translate tests are already using the correct |
|
@copilot The dev branch has updates. Sync changes. |
|
@copilot The dev branch has updates. Sync changes. |
|
There was a problem hiding this comment.
Pull request overview
This PR suppresses a known, benign transformers warning when loading the scb_1m_th-en_spm model in ThEnTranslator, and updates project citation metadata with a DOI. The goal is to keep test output clean while preserving existing translation behavior and to improve citation information.
Changes:
- Wrap
TransformerModel.from_pretrainedinThEnTranslator.__init__with awarnings.catch_warnings()context and a targeted, case-insensitivefilterwarningsregex for the specific model-type mismatch warning. - Add
import warningstopythainlp/translate/en_th.pyto support the new suppression logic. - Add the Zenodo DOI (
10.5281/zenodo.3519354) toCITATION.cfffor more complete citation metadata.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
pythainlp/translate/en_th.py |
Introduces a scoped warnings filter around TransformerModel.from_pretrained to ignore the specific camembert→roberta model-type warning while loading the Thai–English translation model. |
CITATION.cff |
Adds the Zenodo DOI entry to align citation metadata with the published record. |
|
@wannaphong please see if this one is ready. |



What do these changes do
Suppresses the transformers warning "Using a model of type camembert to instantiate a model of type roberta" when loading the
scb_1m_th-en_spmtranslation model inThEnTranslator.__init__().What was wrong
The pre-trained
scb_1m_th-en_spmmodel checkpoint contains a CamemBERT configuration but fairseq loads it as a RoBERTa-compatible transformer. This triggers a model type mismatch warning from the transformers library during test execution.How this fixes it
Wraps
TransformerModel.from_pretrained()in awarnings.catch_warnings()context manager with a targeted filter for the specific warning pattern. The filter uses case-insensitive regex matching to handle potential message variations.Your checklist for this pull request
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.